﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefInbound" :model="stateInbound.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_SheetId_FormItem" prop="Entity.SheetId" :label="$t('message.autotrans._Model_Inbound_SheetId')">
            <el-input v-model="stateInbound.vmModel.Entity.SheetId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_SheetNo_FormItem" prop="Entity.SheetNo" :label="$t('message.autotrans._Model_Inbound_SheetNo')">
            <el-input v-model="stateInbound.vmModel.Entity.SheetNo" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_InMode_FormItem" prop="Entity.InMode" :label="$t('message.autotrans._Model_Inbound_InMode')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Inbound_InMode')}), trigger: 'blur' }]" >
            <el-select v-model="stateInbound.vmModel.Entity.InMode" disabled clearable>
               <el-option key="Manual" value="Manual" :label="$t('message.autotrans._Enum_InOutEnum_Manual')"></el-option>
               <el-option key="Sys" value="Sys" :label="$t('message.autotrans._Enum_InOutEnum_Sys')"></el-option>
               <el-option key="Scan" value="Scan" :label="$t('message.autotrans._Enum_InOutEnum_Scan')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_MaterialId_FormItem" prop="Entity.MaterialId" :label="$t('message.autotrans._Model_Inbound_Material')">
            <el-select v-model="stateInbound.vmModel.Entity.MaterialId" disabled clearable>
               <el-option v-for="item in stateInbound.AllMaterials" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_InQty_FormItem" prop="Entity.InQty" :label="$t('message.autotrans._Model_Inbound_InQty')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Inbound_InQty')}), trigger: 'blur' }]" >
            <el-input v-model="stateInbound.vmModel.Entity.InQty" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_InBatch_FormItem" prop="Entity.InBatch" :label="$t('message.autotrans._Model_Inbound_InBatch')">
            <el-input v-model="stateInbound.vmModel.Entity.InBatch" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_InboundDate_FormItem" prop="Entity.InboundDate" :label="$t('message.autotrans._Model_Inbound_InboundDate')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Inbound_InboundDate')}), trigger: 'blur' }]" >
            <el-input v-model="stateInbound.vmModel.Entity.InboundDate" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_InOperator_FormItem" prop="Entity.InOperator" :label="$t('message.autotrans._Model_Inbound_InOperator')">
            <el-input v-model="stateInbound.vmModel.Entity.InOperator" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_SupplierId_FormItem" prop="Entity.SupplierId" :label="$t('message.autotrans._Model_Inbound_SupplierId')">
            <el-input v-model="stateInbound.vmModel.Entity.SupplierId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_SupplierName_FormItem" prop="Entity.SupplierName" :label="$t('message.autotrans._Model_Inbound_SupplierName')">
            <el-input v-model="stateInbound.vmModel.Entity.SupplierName" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_IsValid_FormItem" prop="Entity.IsValid" :label="$t('message.autotrans._Model_Inbound_IsValid')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Inbound_IsValid')}), trigger: 'blur' }]" >
            <el-input v-model="stateInbound.vmModel.Entity.IsValid" disabled clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onCloseInbound"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageWmsManagementInboundDetails;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { inboundApi } from '/@/api/wmsmanagement/inbound';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefInbound = ref();
const stateInbound = reactive({
    vmModel: {
	  Entity:{
        SheetId: '',
        SheetNo: '',
        InMode: undefined,
        MaterialId: null,
        InQty: null,
        InBatch: '',
        InboundDate: undefined,
        InOperator: '',
        SupplierId: null,
        SupplierName: '',
        IsValid: undefined,
        ID:null,
      },

	},
    
    AllMaterials: [] as any[],
});

// 取消
const onCloseInbound = () => {
    closeDialog();
};

// 提交
const onSubmitInbound = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefInbound.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            inboundApi().edit(stateInbound.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/WmsManagement/Inbound/GetMaterialDocs',[],false).then(x=>{stateInbound.AllMaterials = x});
    if (ci.attrs["wtmdata"]) {
		stateInbound.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateInbound.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	inboundApi().get(stateInbound.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(stateInbound.vmModel, data));
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

